import { _decorator, Component, Node } from 'cc';
import { AdComponent } from '../AdComponent';
const { ccclass, property } = _decorator;
import *as cc from "cc";
import { AudioMgr, ENUM_CLIP } from '../Tool/AudioMgr';
import DatasSpace from '../Tool/DatasSpace';
import { WECHAT } from 'cc/env';
@ccclass('Rankl')
export class Rankl extends Component {
  @property(Node)
  viewNode: Node = null;

  btnClose() {
    AudioMgr.Instance.play(ENUM_CLIP.Click);

    this.btnCloseSetting();
  }

  start() {
    console.log('世界排行榜');
    // AdComponent.Instance.show5X5CustomAd();
    AdComponent.Instance.showInterstitialFullShow();
    // tween(this.viewNode).to(0.3, { position:v3(this.viewNode.getPosition().x,-50,0), scale:v3(1.2,0.8,0)}, { easing: 'smooth' }).to(0.3, { position: v3(0,0,0), scale:v3(1,1,0) }, { easing: 'backInOut' }).to(0.3, { scale:v3(1.1,0.9,0)}, { easing: 'backInOut' }).to(0.1, { scale:v3(1,1,0) }, { easing: 'backInOut' }).call(() => {
    // }).start();
    //this.initUserInfoButton();
  }

  protected onEnable(): void {
    //this.getRank();
  }

  btnCloseSetting() {
    // AdComponent.Instance.instance.playAudio(2);
    // AdComponent.Instance.hide5X5customAd();
    cc.tween(this.viewNode).to(0.5, { position: cc.v3(0, this.viewNode.getPosition().y + 1600, 0) }, { easing: 'backInOut' }).call(() => {
      this.node.removeFromParent();
      this.node.destroy();

    }).start();
  }

  initRankInfo() {

  }


  public getRank() {
    if (window["wx"]) {
      window["wx"].postMessage({
        event: 'getRank'
      });
    }
  }

  public static setRank(data) {
    if (window["wx"]) {
      window["wx"].postMessage({
        event: 'setScore',
        score: data
      });
    }

  }
}